up: programming:c  
c programming
environment variables
What links here?

accessing environment variables

char * getenv(const char * name);


Alternately, environment variables may be accessed by using the special form of main():
int main(int argc, char * argv[], char *envp[]);
At startup, the variable envp Is set to point to the process's environment, which is in the form of an array of C-strings. The last element in the array is a NULL pointer indicating the end of the array. This enables you traverse the entire array easily:

//execute loop so long as envp[n] isn't NULL
for (int n=0; envp[n]; n++) {
    cout << envp[n]<< endl;
}


setting environment variables

int putenv(const char * var);
var must be of the form varname=value. This does not affect the master environment, only the copy used by the currently running program, which is then inherited by any child processes.

References:



http://www.informit.com/guides/content.aspx?g=cplusplus
programming:c:environment variables
filename:programming:c:environment variables
filename:programming%3Ac%3Aenvironment%20variables
last edit:February 06 2010 08:55:24 (5202 days ago)
ct = 1714983275.000000 = May 06 2024 04:14:35
ft = 1265464524.000000 = February 06 2010 08:55:24
dt = 449518751.000000